#comments-start - More Info Dialog
[SCRIPT NAME]Copy File Contents To Clipboard
Description:
    - Copies content from a specified file and puts it on the clipboard.

Arguments:
    - Arg1: Path to target file (Required) - e.g. C:\MyFiles\myfile.txt
    - Arg2: The number of characters to read. [Optional]
        - By default, all characters are copied to the clipboard
#comments-end - More Info Dialog

#include <Include\WinClickPro.au3>
#include <Include\File.au3>
#include <Include\ClipBoard.au3>

Func Main()
	Local $sFilePath = ""
	Local $iCount = -1 ; Default which reads the entire file
	Local $fileHandle
	Local $sContent = ""

	;
	; This script has 1 required argument and 1 optional.
	;
	If $CmdLine[0]  < 1 Then
		_DisplayErrorAndExit("Invalid argument count detected!" & @LF & "Count: " & $CmdLine[0])
	EndIf

	$sFilePath = $CmdLine[1];

	;
	; Did the user specify the optional character count?
	;
	If $CmdLine[0] > 1 Then
		$iCount = $CmdLine[2]
		If $iCount == "" Then
			$iCount = 0 ; User passed in a blank Arg, reset to default.
		EndIf
	EndIf

	$fileHandle = FileOpen($sFilePath, 0) ; Open in read mode

	;
	; Check if file opened for reading OK
	;
	If $fileHandle = -1 Then
		_DisplayErrorAndExit("Unable to open the specified file." & @LF & "File: " & $sFilePath)
	EndIf

	$sContent = FileRead($fileHandle, $iCount)
	FileClose($fileHandle)
	ClipPut($sContent)
EndFunc

Main()
Exit @error